#include <iostream>
using namespace std;
//#include <map>
int size = 0;

int* copy(int array[], const int length) {
    int temp[length];       //临时存储array中非重复元素的数组
    //int size = 0;           //保存array中非重复元素的变量
    bool flag = true;
    for (int i = 0; i < length; i++) {
        for (int j = 0; j < ::size; j++) {
            if (temp[j] == array[i]) {
                flag = false;
            }
        }
        if (flag) {
            temp[::size] = array[i];
            ::size++;
        } else {
            flag = true;
        }
    }
    int *reslut = new int[::size];   //得到的结果
    for (int i = 0; i < ::size; i ++) {
        reslut[i] = temp[i];
    }

    return reslut;
}

int main() {
    int array[] = {2, 1, 2, 2, 5, 1, 3, 5};
    int length = sizeof(array) / sizeof(array[0]);
    //cout << length << endl;
    int *reslut = copy(array, length);
    for (int i = 0; i < ::size; i++) {
        cout << *(reslut + i ) << endl;
    }

    return 0;
}
